import App from './App'

import {
	$http
} from '@escook/request-miniprogram'
uni.$http = $http
$http.baseUrl = 'https://wechat.atptest.com:44386'
$http.beforeRequest = function(options) {
	options.header = {
		'content-type': 'application/x-www-form-urlencoded',
		'Authorization': 'Basic QXBpX1dlYjpBcGlfV2Vi'
	},
	uni.showLoading({
		title: '加载中...'
	})
}

Vue.prototype.$getdateMonth = function(type, num) {
	const date = new Date()
	let year = date.getFullYear()
	let month = date.getMonth() + 1
	let day = date.getDate()
	if (type === 'start') {
		month = month - num
	} else if (type === 'end') {
		month = month + num
	} else if (type === 'center') {
		day = day + num
	}
	month = month > 9 ? month : '0' + month
	day = day > 9 ? day : '0' + day
	return `${year}-${month}-${day}`
}
$http.afterRequest = function(options) {
	uni.hideLoading()
}

uni.$showMsg = function(title = '加载失败', duration = 2000) {
	uni.$showToast({
		title,
		duration,
		icon: 'error'
	})
}

// #ifndef VUE3
import Vue from 'vue'

import uView from '@/uni_modules/uview-ui'
Vue.use(uView)

import store from "./store/index"

Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
	...App,
	store
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif
